<!---
  @author: HuangMingSheng
  @description: 按钮组件
-->
<template>
  <button
    :class="[
      'ms-button',
      `ms-button--${type}`,
      { 'ms-button--disabled': disabled },
    ]"
    :disabled="disabled"
    @click="handleClick"
  >
    <slot></slot>
  </button>
</template>

<script setup lang="ts">
interface Props {
  type?: "primary" | "secondary" | "danger";
  disabled?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
  type: "primary",
  disabled: false,
});

const emit = defineEmits<{
  click: [event: MouseEvent];
}>();

const handleClick = (event: MouseEvent) => {
  if (!props.disabled) {
    emit("click", event);
  }
};

defineOptions({
  name: "MsButton",
});
</script>

<style lang="less" scoped>
@import "./button.less";
</style>
